import { API, BASE_URL } from 'js/config'
import $http from 'js/request'

// 判断用户是否已存在
export const apiExistence = userName => {
  return $http.post(`${API}user/userExistInfo`, { userName })
}

// 发送验证码
export const apiSendCode = mobile => {
  return $http.post(`${API}msgSet/sendMsg`, { mobile })
}

// 注册协议
export const apiRegProtocol = () => {
  return $http.post(`${API}user/agreement`, { })
}

// 注册
export const apiRegister = (mobile, password, smsCode, type = '1') => {
  return $http.post(`${API}user/register`, { mobile, password, smsCode, type })
}

// 登录
export const apiLogin = (username, password) => {
  return $http.post(`${API}user/login`, { username, password })
}

// 修改密码
export const apiResetPsd = (password, newPassword, access_token) => {
  return $http.post(`${API}user/alertPassWord`, { access_token, password, newPassword })
}

// 找回密码
export const apiForgetPsd = (mobile, smsCode, newPassword) => {
  return $http.post(`${API}user/getBackPassWord`, { mobile, smsCode, newPassword })
}

// 关于我们
export const apiAboutUs = (type = 1) => {
  return $http.post(`${API}title/more`, { type })
}

// 购物咨询
export const apiHelpCenter = title => {
  return $http.post(`${BASE_URL}api/app/v1/title/article`, { title })
}

// 查询热点
export const apiHotspotType = () => {
  return $http.post(`${API}hotsport/selectHotspotType`, { })
}

// 通过热点ID查询热点类型内容
export const apiHotspot = (access_token, id) => {
  return $http.post(`${API}hotsport/selectHotspotInfo`, { access_token, id })
}

// 通过热点内容ID查询内容
export const apiHotspotInfo = id => {
  return $http.post(`${API}hotsport/selectHotspotInfoContent`, { id })
}

// 点赞(再次点赞则取消)
export const apiGiveUp = params => {
  return $http.post(`${API}hotsport/giveUp`, { ...params })
}

// 新增我的足迹信息
export const apiAddFootPrint = (access_token, goodsId, storeId) => {
  return $http.post(`${API}footPrint/addFootPrint`, { access_token, goodsId, storeId })
}

// 我的足迹列表
export const apiFootPrintList = (access_token) => {
  return $http.post(`${API}footPrint/findFootPrint`, { access_token })
}

// 删除我的足迹
export const apiDelFootPrint = (access_token, ids) => {
  return $http.post(`${API}footPrint/deleteFootPrint`, { access_token, ids })
}

// 根据当前用户id查询收藏夹商品
export const apiFavoriteGoods = (access_token) => {
  return $http.post(`${API}favorite/selectFavoriteAll`, { access_token })
}

// 根据当前用户id查询收藏夹商品
export const apiFavoriteStore = (access_token, currentPage, showCount = 20) => {
  return $http.post(`${API}favorite/selectFavoriteStoreAll`, { access_token, currentPage, showCount })
}

// 收藏商品
export const apiAddFavoriteGoods = (favoriteGoodsList) => {
  return $http.post(`${API}favorite/addFavorite`, { ...favoriteGoodsList })
}
// 删除收藏的商品
export const apiDeleteFavoriteGoods = (favoriteGoodsIdList) => {
  return $http.post(`${API}favorite/deleteFavorite`, { ...favoriteGoodsIdList })
}

// 获取分类title
export const apiClassMenu = () => {
  return $http.post(`${API}goodsClass/queryGoodsClassAll`, { })
}
// 获取分类列表
export const apiClassContent = (type, parentId) => {
  return $http.post(`${API}goodsClass/queryGoodsClassChilds`, { type, parentId })
}

// 获取分类商品列表
export const apiGetGoodsList = (getGoodsListParams) => {
  return $http.post(`${API}goodsClass/queryGoodsListByClassId`, { ...getGoodsListParams })
}
// 查询全部地址
export const apiAddressAll = (access_token, currentPage = 1, showCount = 20) => {
  return $http.post(`${API}address/selectAddressAll`, { access_token, currentPage, showCount })
}

// 新增地址
export const apiAddAddress = (access_token, params) => {
  return $http.post(`${API}address/addAddress`, { access_token, ...params })
}

// 修改地址
export const apiEditAddress = (access_token, params) => {
  return $http.post(`${API}address/editAddress`, { access_token, ...params })
}

// 删除地址
export const apiDelAddress = (access_token, id) => {
  return $http.post(`${API}address/deleteAddress`, { access_token, id })
}

// 设置默认地址
export const apiDefaultAddress = (access_token, id) => {
  return $http.post(`${API}address/editDefault`, { access_token, id })
}

// 根据主键ID获取单条地址信息
export const apiAddressById = (access_token, id) => {
  return $http.post(`${API}address/selectAddressById`, { access_token, id })
}

// 获取所有区域的接口
export const apiArea = () => {
  return $http.post(`${API}area/selectAreaAll`, { })
}

// 查看个人信息
export const apiUserInfo = access_token => {
  return $http.post(`${API}valueAdd/selectPersonalInfor`, { access_token })
}

// 查看个人信息
export const apiEditUserInfo = (access_token, params) => {
  return $http.post(`${API}valueAdd/editPersonalInfor`, { access_token, ...params })
}

// 图片上传
export const apiImgUpload = (path) => {
  return $http.post(`${API}Img/ImgSwfUpload`, { path })
}

// 首页模板商品和商品列表
export const apiIndexFloor = (currentPage) => {
  return $http.post(`${API}goodsfloor/selectGoodsFloorAll`, { currentPage })
}

// 导航频道楼层信息
export const apiChannelFloor = chId => {
  return $http.post(`${API}channelfloor/selectChannelsFloorAllForApp`, { chId })
}

// banner（导航广告）
export const apiIndexBanner = (chId = '') => {
  return $http.post(`${API}banner/queryBannerByChannelId`, { chId })
}

// 商品详情
export const apiGoodsDetail = (id, access_token) => {
  return $http.post(`${API}goods/queryGoodsById`, { id, access_token })
}

// 商品评价记录
export const apiGoodsCommon = (goodsId, currentPage, evaluateBuyerVal, showCount = 20) => {
  return $http.post(`${API}evaluate/selectEvaluateAll`, { goodsId, currentPage, showCount, evaluateBuyerVal })
}

// 商品搜索
export const apiSearch = (params) => {
  return $http.post(`${API}search/searchGoodsList`, { ...params })
}

// 根据商品id查询列表获取
export const apiGoodsListByIds = goodsIdList => {
  return $http.post(`${API}goods/queryListByGoodsIds`, { goodsIdList })
}

// 新增购物车接口.
export const apiAddCart = params => {
  return $http.post(`${API}goodsCart/addGoodsCart`, { ...params })
}

// 查询购物车接口.
export const apiSelectCartAll = access_token => {
  return $http.post(`${API}goodsCart/selectGoodsCartAll`, { access_token })
}

// 确认订单查询购物车传来的订单数据接口
export const apiSelectAllOrder = (access_token, receiverAddrId, cartStatus = '2') => {
  return $http.post(`${API}goodsCart/selectBalanceAll`, { access_token, receiverAddrId, cartStatus })
}

// 获取邮费
export const apiShipPrice = (receiver_addr_id, goodsList) => {
  return $http.post(`${API}goodsCart/getshipPrice`, { receiver_addr_id, goodsList })
}

// 新增订单
export const apiAddOrder = params => {
  return $http.post(`${API}orderForm/addOrderForm`, { ...params })
}

// 猜你喜欢
export const apiRecommendList = (id, currentPage = 1, showCount = 10) => {
  return $http.post(`${BASE_URL}api/web/v2/guess/guessYouLike`, { id, currentPage, showCount })
}

// 根据订单id，订单详情
export const apiOrderDetail = (access_token, ids) => {
  return $http.post(`${API}orderForm/selectOrderFormByIds`, { access_token, ids })
}

// 微信付
export const apiOrderPay = (access_token, type, id) => {
  return $http.post(`${API}valueAdd/H5ApplyWebOrderFormPay`, { access_token, type, id })
}
